TaskGridCtl = Ext.extend(GridPanelCtl, {

			getCmItems : function() {

				var items = [this.getCmItem('taskId', 'taskId', false),
						this.getCmItem('programId', 'programId', false),
						this.getCmItem('keyFramePath', 'keyFramePath', false),
						this.getCmItem('auditMemo', 'auditMemo', false),
						this.getCmItem('节目名称', 'taskName', true),
						this.getCmItem('提交人', 'uploadUsername', true),
						this.getCmItem('提交时间', 'createTime', true),
						this.getCmItem('当前状态', 'taskStatus', true),
						this.getCmItem('文件名称', 'file', false),
						this.getCmItem('节目时长', 'file', false),
						this.getCmItem('节目分类', 'programClass', true),
						this.getCmItem('所属栏目', 'programColumn', true)]

				return items;
			},
			getCmItem : function(name, attId, isCm) {

				return {
					name : name,
					attId : attId,
					isCm : isCm
				}

			},
			getCommonConfig : function() {

				var config = {
					region : 'center'
				};

				return config;

			},
			configBbar : function(config) {

				var store = this.store;

				var barConfig = {
					pageSize : 5,
					store : store,
					displayInfo : true,
					autoWidth : true,
					emptyMsg : "无记录"
				};
				barConfig = this.configBbarItems(barConfig);

				var bar = new Ext.PagingToolbar(barConfig);

				config.bbar = bar;

				return config;

			},
			configBbarItems : function(config) {

				var items = ['-', {
							// iconCls : 'badd',
							text : '通过',
							handler : this.auditPass,
							scope : this
						}, '-', {
							// iconCls : 'bdel',
							text : '不通过',
							handler : this.auditNotPass,
							scope : this
						}];

				config.items = items;

				return config;

			},
			getStoreUrl : function() {

				var resource = 'auditList.do';
				var server = cf.getC('s');
				var url = server.getUrl({
							resource : resource,
							act : 'r'
						});
				return url;
			},
			load : function(node) {
				var store = this.store;
				this.listType = node.id;
				store.baseParams = {
					listType : node.id
				};
				store.load();
				this.changeCmpModel();
			},
			changeCmpModel : function() {
				// this.changeBbarModel();
			},
			changeBbarModel : function() {
				var bbar = this.cmp.getBottomToolbar();
			},
			rowdblclick : function(gird, index) {
				var record = this.getRecord(index);
				this.loadByRecord(record);
			},
			getRecord : function(index) {
				var store = this.store;
				return store.getAt(index);
			},
			loadByRecord : function(record) {

				var pc = cf.getC('pc');
				pc.open(record.get('programId'));

				var kfc = cf.getC('kfc');
				kfc.load(record);

				var aac = cf.getC('aac');
				aac.load(record);

				var avc = cf.getC('avc');
				avc.load(record);

				var mmc = cf.getC('mmc');
				mmc.load(record);
			},
			rowcontextmenu : function(g, rowIndex, e) {

				var listType = this.listType;
				if (listType == 'onaudit') {
					var menuConfig = this.getMenuConfig();
					var menu = new Ext.menu.Menu(menuConfig);
					this.menu = menu;
					e.preventDefault();
					menu.showAt(e.getXY());
				}

			},
			getMenuConfig : function(g, rowIndex, e) {

				var config = {
					items : [this.getMenuItemConfig('审核通过', this.auditPass),
							this.getMenuItemConfig('审核不通过', this.auditNotPass)]
				};
				return config;

			},
			auditPass : function() {
				var status = 1;
				// var c = cf.getC('tgc');

				// 生成一个target;
				var twc = cf.getC('twc');
				twc.show();

				// this.updateTask(status);

			},
			updateTask : function(status) {

				var params = this.getUpdateParams(status);
				
				if(params == null){
					return;
				}
				var sPara = {
					resource : 'auditList.do',
					act : 'u',
					params : params,
					cbf : this.updateSucess,
					scope : this
				};

				var s = cf.getC('s');
				s.request(sPara);
			},
			updateSucess : function(response) {
				
				this.store.reload();
				
				// alert(Ext.encode(response));
			},
			getUpdateParams : function(status) {

				var record = this.getSelectedRecord();
				
				if(!record){
					Ext.Msg.alert("提示", '请选择一条任务!');
					return null;
				}
				var avc = cf.getC('avc');
				var auditMemo = avc.getValue();

				var task = {
					taskId : record.get('taskId'),
					taskStatus : status,
					auditMemo : auditMemo,
					programId : record.get('programId')
				};

				task = Ext.encode(task);

				var tfc = cf.getC('tfc');

				var destIdArray = tfc.getDestIdArray();
				var classId = tfc.getClassId();
				var isEdit = tfc.getIsEdit();
				var memo = tfc.getMemo();

				destIdArray = Ext.encode(destIdArray);
				
				return {
					task : task,
					destIdArray : destIdArray,
					classId : classId,
					isEdit : isEdit,
					memo : memo
				}
			},
			getSelectedRecord : function() {
				var sm = this.cmp.getSelectionModel();
				return sm.getSelected();
			},
			auditNotPass : function() {
				var status = 2;
				var c = cf.getC('tgc');
				c.updateTask(status);
			},
			getMenuItemConfig : function(text, handler) {
				return {
					text : text,
					handler : function(m) {
						var tgc = cf.getC('tgc')
						var menu = tgc.menu;
						menu.hide();
						handler();
					}
				};

			}

		});
